package cn.iocoder.yudao.module.erp.controller.admin.purchaseplan.vo.purchasematerialdetail;

import cn.hutool.core.collection.CollectionUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Schema(description = "管理后台 - 物料采购计划明细 Response VO")
@Builder
@Data
public class PurchaseMaterialDetailExportRespVO {
    @Schema(description = "成功的内容")
    private List<PurchaseMaterialDetailExportVO> successList;
    @Schema(description = "失败的内容")
    private List<PurchaseMaterialDetailExportVO> failList;
    @Schema(description = "失败的message")
    private List<String> errorMessageList;
    public void setErrorMessageList() {
        if (CollectionUtil.isEmpty(failList)) {
            this.errorMessageList = Collections.emptyList();
        }else {
            this.errorMessageList = failList.stream()
                    .map(PurchaseMaterialDetailExportVO::getMessage)
                    .distinct()
                    .collect(Collectors.toList());
        }
    }
}